import React from 'react'
import {connect} from 'react-redux'
import {FormattedMessage} from 'react-intl';
import NewUser from '../../components/Users/new.js'
import userManageAction  from '../../actions/userManageAction.js'

const Userlist = React.createClass({
	render(){
		return(
			<tbody>
			{
				this.props.users.map((item,index) => {
					return (
						<tr key={index}>
							<td>{item.username}</td>
						</tr>
					)
				})
			}
			</tbody>
		)
	}
})

const UserManage = React.createClass({
	componentWillMount() {
	    const {fetchApply} =  this.props;
	    fetchApply();
	},
	render: function(){
		const {users} =  this.props;
		return (
			<div>
				<NewUser />
				<table>
					<thead>
						<tr>
							<th><FormattedMessage id='user name' defaultMessage='账号名称'
							/></th>
						</tr>
					</thead>
					<Userlist  users={users}/>
				</table>
			</div>
		)
	}
});
const mapStateToProps = (state) => {
  return {
    users: state.users
  }
}

module.exports = connect(mapStateToProps, userManageAction)(UserManage);





